#include "node.h"
#include <stdio.h>

static int outsideGlobal=0;
static int NodesDeleted=0;

namespace nav
{
    //Every Node at its initialisation has a Position a Original Weight, and the Information if the Node has been explored via Sensors.
    Node::Node(int posX, int posY, int weight, bool Explored)
    {
        outsideGlobal++;
        this->posX=posX;
        this->posY=posY;
        this->weight=weight;

        this->tweight=0;
        this->explored=Explored;
        this->infoPath=false;
        this->accumulatedPathCosts=0;

        //ctor
    }

    //Equality Operator - and yes i tried to define a == operator and botched it somehow
    bool Node::Equals(  Node *other)
    {
         return (this->posX==other->posX && this->posY== other->posY );
    }

    //copy Constructor
    Node::Node( const Node& other)
    {
        this->explored=other.explored;
        this->posX=other.posX;
        this->posY=other.posY;
        this->weight=other.weight;
        this->tweight=other.tweight;
        this->infoPath=other.infoPath;
        this->accumulatedPathCosts=other.accumulatedPathCosts;
    //
    //    return other;
        //copy ctor
    }

    //prints out the Nodes Debugdata
    void Node::PlotNodeData()
    {
       printf("===== Node Debug Data ======"   );
       printf("Predecessor: %d", this->getPredecessor());

       printf("X:%d",this->posX                 );
       printf("Y:%d",this->posY                 );

       printf("=============================");
        (*this->getPredecessor()).PlotNodeData();
        //Sleep(4000);
    }


    //Destructor- Enemy of all Class based societys ;)
    Node::~Node()
    {

        NodesDeleted++;
        //dtor
    }
}
